package controllers

import (
	"github.com/gin-gonic/gin"
	"net/http"
	"week2a/models/es"
	"week2a/models/mysql"
	"week2a/types"
)

func SyncVideoEs(c *gin.Context) {
	es.SyncVideoEs()
	c.JSON(http.StatusOK, gin.H{
		"code":    http.StatusOK,
		"message": "同步数据成功",
	})
}
func HighlightVideoEs(c *gin.Context) {
	var data types.Video
	if err := c.ShouldBindJSON(&data); err != nil {
		c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
		return
	}
	videoEs := es.HighlightVideoEs(data.VideoTitle, 1)
	c.JSON(http.StatusOK, gin.H{
		"code":    http.StatusOK,
		"message": "查询成功",
		"data":    videoEs,
	})
}
func VideoList(c *gin.Context) {
	list := mysql.GetVideoList()
	c.JSON(http.StatusOK, gin.H{
		"code":    http.StatusOK,
		"message": "查询成功",
		"data":    list,
	})
}
